<div class='pages'>
  <div class='left'>
    共<b><%= @messages.total_entries %></b>贴
  </div>
  <div class='search'>
    
  </div>
  <div class='right will_paginate'>            
    <%= remote_will_paginate @messages, :go_to_js_function => "fetion_#{@fetion.id}_go_to" %>
  </div>
</div>
<div class='messages'>
  <table cellspacing="1" cellpadding="1" border="0">         
    <tr>
      <th rowspan='2'>类型</th>
      <th rowspan='2'>来自</th>
      <th class='h'><%= FetionMessage::ApplicationConfirmed.human_name %></th>
      <th class='h'><%= FetionMessage::BuddyApplication.human_name %></th>
      <th class='h' colspan='2'><%= FetionMessage::BuddyMessage.human_name %></th>
      <th class='h' colspan='2'><%= FetionMessage::BuddyState.human_name %></th>
      <th rowspan='2' class='h'><%= FetionMessage::ClientState.human_name %></th>      
      <th rowspan='2'>接收于</th>
      <th rowspan='2'>状态</th>
    </tr>
    <tr>
      <th>加好友</th>
      <th>描述</th>
      <th>消息</th>
      <th>发送于</th>
      <th>先前</th>
      <th>当前</th>
    </tr>
    <% @messages.each do |message| %>
    <tr>
      <td><%= message.class.human_name %></td>
      <td><%= message.user.try(:nick_name) %></td>
      <% if message.is_a?(FetionMessage::ApplicationConfirmed) %>
      <td><%= message.agreed ? '同意' : '不同意' %></td>
      <% else %>
      <td></td>
      <% end %>
      <%  if message.is_a?(FetionMessage::BuddyApplication) %>
      <td><%= message.desc %></td>
      <% else %>
      <td></td>
      <% end %>
      <% if message.is_a?(FetionMessage::BuddyMessage) %>
      <td class='left' title='<%= message.message %>'>        
        <%= truncate message.message, :length => 10 %>      
      </td>
      <td><%= time_ago_in_words message.sent_on,false %>前</td>
      <% else %>
      <td></td>
      <td></td>
      <% end %>      
      <% if message.is_a?(FetionMessage::BuddyState) %>
      <td><%= t message.before_state %></td>
      <td><%= t message.current_state %></td>
      <% else %>
      <td></td>
      <td></td>
      <% end %>
      <% if message.is_a?(FetionMessage::ClientState) %>
      <td><%= t message.client_state %></td>
      <% else %>
      <td></td>
      <% end %>
      <td><%= time_ago_in_words message.recieved_at %>前</td>
      <td><b class='<%= message.status %>'><%= t message.status %></b></td>
    </tr>
    <% end %>
    <% if @messages.empty? %>
    <tr>
      <td align="center" colspan="11">无短信</td>
    </tr>
    <% end %>
  </table>
</div>
<div class='pages'>
  <div class='left'>
    共<b><%= @messages.total_entries %></b>贴
  </div>
  <div class='right will_paginate'>            
    <%= remote_will_paginate @messages, :go_to_js_function => "fetion_#{@fetion.id}_go_to" %>
  </div>
</div>